package pw_coding

import (
	"fmt"
	"path"
	"sasuke/utils"
)

// 包结构
type Folder struct {
	F
	Files   []File
	Folders []Folder
}

func (f *Folder) Create() error {
	// 创建目录
	utils.Create2Dir(path.Join(f.FPath, f.Name))
	// 创建文件
	if f.Files != nil && len(f.Files) > 0 {
		for fileIndex, file := range f.Files {
			if file.Create() == nil {
				fmt.Println("成功创建文件：[", fileIndex, "]", file.Name)
			}
		}
	}
	// 创建包
	if f.Folders != nil && len(f.Folders) > 0 {
		for folderIndex, folder := range f.Folders {
			if folder.Create() == nil {
				fmt.Println("成功创建包：[", folderIndex, "]", folder.Name)
			}
		}
	}
	return nil
}
